package jhavelogger.models;

import java.util.Date;

/**
 * Represents a full log that can be saved to/read from the database. These
 * are constructed from multiple JHaveLog objects by a log visitor.
 * 
 * @author Jared Schlicht
 *
 */
public class DBLog {
    private String username;
    private String ip;
    private String algorithmName;
    private Date date;
    private String city;
    private String region;
    private String country;

    /**
     * Creates a new DBLog object.
     * 
     * @param username username of the user that viewed the algorithm
     * @param ip ip address of the user that viewed the algorithm
     * @param algorithmName the algorithm that the user viewed
     * @param date the date that the user viewed the algorithm
     * @param city the user's city. May be null.
     * @param region the user's region. May be null.
     * @param country the user's country. May be null.
     */
    public DBLog(String username, String ip, String algorithmName, Date date, String city, String region, String country) {
	this.username = username;
	this.ip = ip;
	this.algorithmName = algorithmName;
	this.date = date;
	this.city = city;
	this.region = region;
	this.country = country;
    }

    /**
     * Set this log's username
     * @param username the username to set
     */
    public void setUsername(String username) {
	this.username = username;
    }

    /**
     * Gets this log's username
     * @return the username
     */
    public String getUsername() {
	return username;
    }

    /**
     * Sets this log's ip address
     * @param ip the ip to set
     */
    public void setIp(String ip) {
	this.ip = ip;
    }

    /**
     * Gets this log's ip address
     * @return the ip address
     */
    public String getIp() {
	return ip;
    }

    /**
     * Sets this log's algorithm name
     * @param algorithmName the algorithmName to set
     */
    public void setAlgorithmName(String algorithmName) {
	this.algorithmName = algorithmName;
    }

    /**
     * Gets this log's algorithm name.
     * @return the algorithmName
     */
    public String getAlgorithmName() {
	return algorithmName;
    }

    /**
     * Sets this log's date
     * @param date the date to set
     */
    public void setDate(Date date) {
	this.date = date;
    }

    /**
     * Gets this log's date
     * @return the date
     */
    public Date getDate() {
	return date;
    }

    /**
     * Sets this log's city
     * @param city the city to set
     */
    public void setCity(String city) {
	this.city = city;
    }

    /**
     * Gets this log's city
     * @return the city
     */
    public String getCity() {
	return city;
    }

    /**
     * Sets this log's region (or state)
     * @param region the region to set
     */
    public void setRegion(String region) {
	this.region = region;
    }

    /**
     * Gets this log's region (or state)
     * @return the region
     */
    public String getRegion() {
	return region;
    }

    /**
     * Sets this log's country
     * @param country the country to set
     */
    public void setCountry(String country) {
	this.country = country;
    }

    /**
     * Gets this log's country
     * @return the country
     */
    public String getCountry() {
	return country;
    }
    
    @Override
    public String toString() {
	return this.getIp() + " " + this.getUsername() + " " + this.getAlgorithmName() + " " + this.getDate().toLocaleString() + " " + this.getCity() + " " + this.getRegion() + " " + this.getCountry();
    }
}
